package com.systop.mapper;

import com.systop.pojo.Goods;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface GoodsMapper {
    @Insert("insert into goods (goods_user_id,goods_status_id,goods_property_id,goods_type_id,goods_name,goods_price,goods_photo,goods_describtion,remark,goods_times)values(#{goods_user_id},#{goods_status_id},#{goods_property_id},#{goods_type_id},#{goods_name},#{goods_price},#{goods_photo},#{goods_describtion},#{remark},#{goods_times})")
    Integer addGoods(Goods goods);
    @Select("select * from goods")
    List<Goods> findall();
    @Update("<script>"+
            "update goods set"+
            "<if test=\"goods_user_id != null\">goods_user_id=#{goods_user_id},</if>"+
            "<if test=\"goods_status_id != null\">goods_status_id=#{goods_status_id},</if>"+
            "<if test=\"goods_property_id != null\">goods_property_id=#{goods_property_id},</if>"+
            "<if test=\"goods_type_id != null\">goods_type_id=#{goods_type_id},</if>"+
            "<if test=\"goods_name != null\">goods_name=#{goods_name},</if>"+
            "<if test=\"goods_price != null\">goods_price=#{goods_price},</if>"+
            "<if test=\"goods_photo != null\">goods_photo=#{goods_photo},</if>"+
            "<if test=\"goods_describtion != null\">goods_describtion=#{goods_describtion}</if>"+
            "<if test=\"remark != null\">remark=#{remark}</if>"+
            "<if test=\"goods_times != null\">goods_times=#{goods_times}</if>"+
            "where goods_id = #{goods_id}" +
            "</script>")
    Integer updGoods(Goods goods);
}
